<template>
  <div>
    <el-card>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>用户管理</el-breadcrumb-item>
        <el-breadcrumb-item>成长值规则</el-breadcrumb-item>
      </el-breadcrumb>
      <h3 style="text-align: left;font-size: 25px;margin-bottom: 0px">成长值规则</h3>

    </el-card>


    <el-card style="margin-top: 20px">
      <h4 style="text-align: left;font-weight: normal;margin-top: 0px">基础任务</h4>
      <el-form ref="form" :model="form" label-width="200px" style="width: 550px;margin: 0 auto" size="small">


        <el-form-item label="登录获得成长值" style="font-size: 14px;text-align: left">
          <el-input v-model="form.loginGet" style="width: 150px">

          </el-input>
        </el-form-item>

        <el-form-item label="注册获得成长值" style="font-size: 14px;text-align: left">
          <el-input v-model="form.registerGet" style="width: 150px">
          </el-input>
        </el-form-item>

        <el-form-item label="完善资料获得成长值" style="font-size: 14px;text-align: left">
          <el-input v-model="form.perfectGet" style="width: 150px">
          </el-input>
        </el-form-item>

      </el-form>
    </el-card>

    <el-card style="margin-top: 20px">
      <h4 style="text-align: left;font-weight: normal;margin-top: 0px">订单任务</h4>
      <el-form ref="form" :model="form" label-width="200px" style="width: 550px;margin: 0 auto" size="small">


        <el-form-item label="每购买一次获得成长值" style="text-align: left">
          <el-input v-model="form.buyGet" style="width: 150px">
          </el-input>
        </el-form-item>

        <el-form-item label="订单每满" style="text-align: left">
          <el-input v-model="form.amount" style="width: 150px">
            <template slot="append">元</template>
          </el-input>

          <span style="margin:0 5px">获得成长值</span>
          <el-input v-model="form.amountGet" style="width: 80px">
          </el-input>
        </el-form-item>

        <el-form-item label="订单总额的" style="text-align: left">
          <el-input v-model="form.ratioGet" style="width: 150px">
          </el-input>
          <span style="margin: 0 5px">%获得成长值</span>
        </el-form-item>

      </el-form>
    </el-card>

    <el-card style="margin-top: 20px">
      <h4 style="text-align: left;font-weight: normal;margin-top: 0px">运营任务</h4>
      <el-form ref="form" :model="form" label-width="200px" style="width: 550px;margin: 0 auto" size="small">

        <el-form-item label="每次分享获得成长值" style="text-align: left">
          <el-input v-model="form.shareGet" style="width: 150px">
          </el-input>
        </el-form-item>

        <el-form-item label="邀请新用户获得成长值" style="text-align: left">
          <el-input v-model="form.inviteGet" style="width: 150px">
          </el-input>
        </el-form-item>

        <el-form-item label="每日签到获得成长值" style="text-align: left">
          <el-input v-model="form.signGet" style="width: 150px">
          </el-input>
        </el-form-item>





        <el-form-item style="text-align: left">
          <el-button type="primary" @click="update">提交</el-button>
        </el-form-item>
      </el-form>
    </el-card>


  </div>

</template>
<script>
    export default {
        data() {
            return {
              form: {
                loginGet: '',
                registerGet: '',
                perfectGet: '',
                buyGet: '',
                amount: '',
                amountGet: '',
                ratioGet: '',
                shareGet: '',
                inviteGet: '',
                signGet: '',
              }
            };
        },
        methods: {

          initGrowForm(){
            let url = "growRule/query"

            this.$axios.get(url)
                .then(res=>{
                  if (res.data.code == 101){
                    this.form = res.data.data
                  }else{
                    this.$message({
                      type:"error",
                      message:res.data.msg,
                      duration:1000
                    })
                  }
                })
          },
          update(){
            let url = "growRule/update"
            this.$axios.put(url,this.form)
                .then(res=>{
                  if (res.data.code == 101){
                    this.$message({
                      type:"success",
                      message:res.data.msg,
                      duration:1000
                    })
                    this.initGrowForm()
                  }else{
                    this.$message({
                      type:"error",
                      message:res.data.msg,
                      duration:1000
                    })
                  }
                })
          }

        },
        created() {
          this.initGrowForm()

        }
    };
</script>
<style lang="less" scoped>
</style>